package edu.neusoft.kongfanfei317.yuejian1.adapter;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;

import com.squareup.picasso.Picasso;

import java.util.List;

import edu.neusoft.kongfanfei317.yuejian1.activity.MasterDetailsActivity;
import edu.neusoft.kongfanfei317.yuejian1.bean.MasterListBean;


public class MasterAdapter extends BaseAdapter<MasterListBean> {

    public MasterAdapter(Context context, List<MasterListBean> items, int layoutResource) {
        super(context, items, layoutResource);
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        ViewHolder viewHolder = (ViewHolder) holder;
        final String foodid = items.get(position).getFood_id();
        final String foodname = items.get(position).getFoodname();
        final String shop_id=items.get(position).getShop_id();
        //final String foodname=items.get(position).getFoodname();
        //String shopaddress = items.get(position).getAddress();
        //final String foodid = items.get(position).getFood_id();
        final String type_id =items.get(position).getType_id();
        final String foodintro = items.get(position).getIntro();
        final String foodprice = items.get(position).getPrice();
        final String foodimg = items.get(position).getPic();

        String price = items.get(position).getPrice();
        viewHolder.tv_name.setText(foodname);
        viewHolder.tv_address.setText(price);
        Picasso.with(context).load(items.get(position).getPic()).into(viewHolder.img);
        viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Log.i("TEST", "onClick: ");
                Intent intent = new Intent(context, MasterDetailsActivity.class);
                //intent.putExtra("foodid", foodid);
                //intent.putExtra("foodname", foodname);

                intent.putExtra("shop_id",shop_id);
                intent.putExtra("foodname",foodname);
                intent.putExtra("foodintro",foodintro);
                intent.putExtra("foodprice",foodprice);
                intent.putExtra("foodimg",foodimg);
                intent.putExtra("foodid",foodid);
                intent.putExtra("typeid",type_id);
                context.startActivity(intent);

            }
        });

    }
}

